﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace DataAccess
{
    public class FS0101DataAccess : FSBase_DataAccess
    {
        #region 模糊检索
        public DataTable Search1(string strUserID, string strUserType)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.AppendLine("   select iAutoID,vcUserID,case vcUserType when 0 then '管理员' when 1 then '普通用户' else '其他' end as vcUserType from sUser  ");
            strSql.AppendLine("   where 1=1  ");
            if (!string.IsNullOrEmpty(strUserID))
            {
                strSql.AppendLine("   and vcUserID like '" + strUserID + "%'  ");
            }
            if (!string.IsNullOrEmpty(strUserType))
            {
                strSql.AppendLine("   and vcUserType = '" + strUserType + "'  ");
            }
            
            return Search(strSql.ToString());
        }
        #endregion

        #region 精确检索
        public DataTable Search2(string strUserID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.AppendLine("   select iAutoID,vcUserID,case vcUserType when 0 then '管理员' when 1 then '普通用户' else '其他' end as vcUserType from sUser  ");
            strSql.AppendLine("   where 1=1  ");
            if (!string.IsNullOrEmpty(strUserID))
            {
                strSql.AppendLine("   and vcUserID = '" + strUserID + "'  ");
            }
            return Search(strSql.ToString());
        }
        #endregion

        #region 删除
        public void Delete(List<string> Items)
        {
            StringBuilder strSql = new StringBuilder();
            foreach (var item in Items)
            {
                strSql.AppendLine("   delete sUser where iAutoID = " + item + "  ");
            }
            update(strSql.ToString());
        }
        #endregion
    }
}
